package com.gwtsz.chart.output.utils;

import java.io.Serializable;

/**
 * Created by reeta.zou on 2016/10/13.
 * K线数据model
 */
public class GTTKDataModel implements Serializable{

    public int priceTime; //时间m
    /**中间价*/
    public double marketPrice;
    /**最高价*/
    public double highPrice;
    /**最低价*/
    public double lowPrice;
    /**开*/
    public double openPrice;
    /**收*/
    public double lastPrice;
    /**涨幅*/
    public double changePrice;
    /**百分比*/
    public float range;

    public void printString(){
        System.out.println("android GTTKDataModel::"+ toString());
    }

    @Override
    public String toString() {
        return "mTime = " + priceTime + ", marketPrice ="+ marketPrice
                + ", openPrice ="+ openPrice+ ", highPrice ="+ highPrice
                + ", closePrice ="+ lastPrice+ ", lowPrice ="+ lowPrice
                + ", changePrice ="+ changePrice+ ", range ="+ range;
    }

    /**
     * 构造函数
     * @param date 报价时间
     * @param open 开盘价
     * @param high 最高价
     * @param low 最低价
     * @param close 收盘价
     * @param mChangePrice 涨跌
     * @param mRange 幅度
     * @param mNewPrice 现价
     */
    public GTTKDataModel(int date, double open, double high, double low,
                         double close, double mChangePrice, float mRange, double mNewPrice) {
        priceTime = date;
        openPrice = open;
        highPrice = high;
        lowPrice = low;
        lastPrice = close;
        changePrice = mChangePrice;
        range = mRange;
        marketPrice = mNewPrice;
    }

    public GTTKDataModel() {
        this(0, 0, 0, 0, 0, 0, 0, 0);
    }

    /**
     * 判断是否牛市(收盘>开盘 白色柱状)
     */
    public boolean isBullish() {
        return lastPrice > openPrice;
    }

    /**
     * 判断是否熊市(收盘<开盘 红色柱状)
     */
    public boolean isBearish() {
        return (lastPrice < openPrice);
    }

    /**
     * 判断开盘和收盘是否相等(相等的话就是画+)
     * @return
     */
    public boolean isUnchanged() {
        return (lastPrice == openPrice);
    }

    /**
     * 复制一个价格类对象到当前对象
     * @param right
     */
    public void copy(GTTKDataModel right) {
        priceTime = right.priceTime;
        openPrice = right.openPrice;
        highPrice = right.highPrice;
        lowPrice = right.lowPrice;
        lastPrice = right.lastPrice;
        changePrice = right.changePrice;
        range = right.range;
        marketPrice = right.marketPrice;
    }

    /**
     * 为当前价格对象设置各类值
     * @param date 报价时间
     * @param high 最高价
     * @param low 最低价
     * @param open 开盘价
     * @param close 收盘价
     */
    public void setGTSQuote(int date, double high, double low, double open, double close) {
        priceTime = date;
        openPrice = open;
        highPrice = high;
        lowPrice = low;
        lastPrice = close;
    }
}
